﻿Public Class RseparacionVentaDetallePagos

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) _
    As List(Of EseparacionVentaDetallePagos)
        Dim separacionVentaDetallePagos As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetallePagos = DseparacionVentaDetallePagos.SeleccionarTodo(descEmpresa, pSeparacionVenta)
                If separacionVentaDetallePagos Is Nothing Then separacionVentaDetallePagos = New List(Of EseparacionVentaDetallePagos)
                'If DisplaySelect Then tpoMonedas.Insert(0, New EseparacionVentaDetallePagos("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetallePagos
    End Function
    Public Shared Function AñadirSeparacion(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.AñadirSeparacion(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVenta(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.AñadirVenta(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.Añadir(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.Eliminar(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function SeleccionarTodoTemporal(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) _
As List(Of EseparacionVentaDetallePagos)
        Dim separacionVentaDetallePagos As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetallePagos = DseparacionVentaDetallePagos.SeleccionarTodoTemporal(descEmpresa, pSeparacionVenta)
                If separacionVentaDetallePagos Is Nothing Then separacionVentaDetallePagos = New List(Of EseparacionVentaDetallePagos)
                'If DisplaySelect Then tpoMonedas.Insert(0, New EseparacionVentaDetallePagos("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetallePagos
    End Function
    Public Shared Function AñadirSeparacionTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.AñadirSeparacionTemporal(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVentaTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.AñadirVentaTemporal(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Verificar(ByVal descEmpresa As String, ByVal Aprobar As String, ByVal Observacion As String, ByVal Usuario As Int32, ByVal idSeparacionVenta As Int32, ByVal idEtapa As Int32, ByVal idProyecto As Int32, ByVal Correlativo As Int32, ByVal EstadoPago As Int32, ByVal tpoGestion As Int32, ByVal idMotivo As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.Verificar(descEmpresa, Aprobar, Observacion, Usuario, idSeparacionVenta, idEtapa, idProyecto, Correlativo, EstadoPago, tpoGestion, idMotivo)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EliminarTemporal(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.EliminarTemporal(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '-------   MENU COBRANZA  ------------'
    Public Shared Function SeleccionarXCobranza(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarXCobranzaDetalle(descEmpresa, pSeparacionVenta)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    Public Shared Function SeleccionarXCobranza2(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarXCobranzaDetalle2(descEmpresa, pSeparacionVenta)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    Public Shared Function SeleccionarXPendientePagos(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarXPendientePagosDetalle(descEmpresa, pSeparacionVenta)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    Public Shared Function SeleccionarTodoPendientePagos(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal wNombre As String, ByVal wDocumento As String) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarTodoPendientePagos(descEmpresa, idProyecto, wNombre, wDocumento)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    Public Shared Function SeleccionarXIngresosDepositoDetalle(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarXIngresosDepositoDetalle(descEmpresa, pSeparacionVenta)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    Public Shared Function cobranzaDetallePagoEdit(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.cobranzaDetallePagoEdit(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function cobranzaDetallePagoFileScan(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.cobranzaDetallePagoFileScan(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '-------   MENU REPORTE  -------------'
    Public Shared Function SeleccionarXPendientePagosDetalleConsolidado(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cobranzas = DseparacionVentaDetallePagos.SeleccionarXPendientePagosDetalleConsolidado(descEmpresa, pSeparacionVenta)
                If cobranzas Is Nothing Then cobranzas = New List(Of EseparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cobranzas
    End Function
    '-------------------------------------'

    Public Shared Function EliminarDistribuir(ByVal descEmpresa As String, ByVal pSeparacionVentaDetallePagos As EseparacionVentaDetallePagos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DseparacionVentaDetallePagos.EliminarDistribuir(descEmpresa, pSeparacionVentaDetallePagos)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function


#Region "           Metodos y Funciones Wilson                    "

    Public Shared Function ReporteIngresosDeposito2(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim Cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Cobranzas = DseparacionVentaDetallePagos.ReporteIngresosDeposito2(descEmpresa, pSeparacionVenta)
                If Cobranzas Is Nothing Then Cobranzas = New List(Of EseparacionVentaDetallePagos)
                'If DisplaySelect Then proformas.Insert(0, New EseparacionVenta("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return Cobranzas
    End Function

    Public Shared Function ReportePendientesPagos2(ByVal descEmpresa As String, ByVal descPago As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetallePagos)
        Dim Cobranzas As List(Of EseparacionVentaDetallePagos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Cobranzas = DseparacionVentaDetallePagos.ReportePendientesPagos2(descEmpresa, descPago, pSeparacionVenta)
                If Cobranzas Is Nothing Then Cobranzas = New List(Of EseparacionVentaDetallePagos)
                'If DisplaySelect Then proformas.Insert(0, New EseparacionVenta("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return Cobranzas
    End Function

#End Region


End Class
